<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<head>
    <title>社交平台</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
</head>
<jsp:include page="/views/header.jsp"/>

<div class="container mt-4">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h5>编辑日志</h5>
                </div>
                <div class="card-body">
                    <form action="${pageContext.request.contextPath}/post/update" method="post">
                        <input type="hidden" name="postId" value="${post.postId}">
                        <div class="mb-3">
                            <textarea class="form-control" name="content" rows="5" required>${post.content}</textarea>
                        </div>
                        <div class="mb-3">
                            <label for="visibility" class="form-label">可见范围</label>
                            <select class="form-select" id="visibility" name="visibility">
                                <option value="public" ${post.visibility eq 'public' ? 'selected' : ''}>公开</option>
                                <option value="friends" ${post.visibility eq 'friends' ? 'selected' : ''}>仅好友可见</option>
                                <option value="private" ${post.visibility eq 'private' ? 'selected' : ''}>仅自己可见</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label for="location" class="form-label">位置</label>
                            <input type="text" class="form-control" id="location" name="location"
                                   value="${post.location}" placeholder="可选">
                        </div>
                        <div class="d-flex justify-content-end">
                            <a href="${pageContext.request.contextPath}/post/detail?id=${post.postId}"
                               class="btn btn-outline-secondary me-2">取消</a>
                            <button type="submit" class="btn btn-primary">保存更改</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<jsp:include page="/views/footer.jsp"/>